<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/HUST_cs_jiekou/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/HUST_cs_jiekou/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/HUST_cs_jiekou/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/HUST_cs_jiekou/images/logo.svg" color="#222">

<link rel="stylesheet" href="/HUST_cs_jiekou/css/main.css">


<link rel="stylesheet" href="/HUST_cs_jiekou/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"gitee.com","root":"/HUST_cs_jiekou/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="一. 概述本实验将学习如何使用MIPSfpga处理器的中断系统。首先，在实验3的基础上，将UART、自定制IP模块等基于AXI4的外设模块的中断信号线连接到MIPSfpga处理器；然后，编写中断处理程序进行演示。">
<meta property="og:type" content="article">
<meta property="og:title" content="实验4-MIPSfpag系统：中断实验">
<meta property="og:url" content="https://gitee.com/live_once/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/index.html">
<meta property="og:site_name" content="接口实验">
<meta property="og:description" content="一. 概述本实验将学习如何使用MIPSfpga处理器的中断系统。首先，在实验3的基础上，将UART、自定制IP模块等基于AXI4的外设模块的中断信号线连接到MIPSfpga处理器；然后，编写中断处理程序进行演示。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/1.png">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/2.png">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/3.png">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/4.png">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/5.png">
<meta property="og:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/6.png">
<meta property="article:published_time" content="2021-02-16T13:47:33.000Z">
<meta property="article:modified_time" content="2021-02-21T01:41:08.958Z">
<meta property="article:author" content="华中科技大学计算机学院">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/1.png">

<link rel="canonical" href="https://gitee.com/live_once/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>实验4-MIPSfpag系统：中断实验 | 接口实验</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/HUST_cs_jiekou/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">接口实验</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/HUST_cs_jiekou/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/HUST_cs_jiekou/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/live_once/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/HUST_cs_jiekou/images/avatar.gif">
      <meta itemprop="name" content="华中科技大学计算机学院">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="接口实验">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          实验4-MIPSfpag系统：中断实验
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-16 21:47:33" itemprop="dateCreated datePublished" datetime="2021-02-16T21:47:33+08:00">2021-02-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-02-21 09:41:08" itemprop="dateModified" datetime="2021-02-21T09:41:08+08:00">2021-02-21</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="一-概述"><a href="#一-概述" class="headerlink" title="一. 概述"></a>一. 概述</h2><p>本实验将学习如何使用MIPSfpga处理器的中断系统。首先，在实验3的基础上，将UART、自定制IP模块等基于AXI4的外设模块的中断信号线连接到MIPSfpga处理器；然后，编写中断处理程序进行演示。</p>
<a id="more"></a>

<h2 id="二-MIPSfpga处理器系统搭建"><a href="#二-MIPSfpga处理器系统搭建" class="headerlink" title="二. MIPSfpga处理器系统搭建"></a>二. MIPSfpga处理器系统搭建</h2><ol>
<li><p>打开实验3的工程，选择File-&gt;Project-&gt;Save as 将工程命名为MIPSFPGA_interrupt,路径自己选择，不要有中文路径就好</p>
<p> <img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/1.png" alt="1"><br> <img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/2.png" alt="2"></p>
</li>
<li><p>点击Open Block Design打于先前的设计。<br> <img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/3.png" alt="3"></p>
</li>
<li><p>将连接MIPSfpga处理器SI_INT[7:0]引脚的Constant模块断开，并将其Const Width修为1，再添加一个8位的 Concat模块；将Concat模块的dout[7:0]引脚连接到MIPSfpga处理器的SI_INT[7:0]；除Concat模块的In4和In5引脚外，其它的Inx引用都连接到前面修改的Constant模块。完成后如下图所示。<br> <img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/4.png" alt="4"></p>
</li>
<li><p>将PWM_w_Int模块的Interrupt_out引脚连接到上面Concat模块的In4引脚，UART16550模块的ip2intc_irpt引脚连接到上面Concat模块的In5引脚。完成后，整个MIPSfpga处理器系统如下图所示。</p>
<p> <img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/5.png" alt="5"></p>
</li>
<li><p>点击Validate Design，对设计的正确性进行校验。校验过程中如果出现警告，点击OK忽略。</p>
</li>
<li><p>点击Generate Block Design，弹出对话框后选择Generate更新MIPSFPGA_System_wrapper文件。<br><img src="/HUST_cs_jiekou/2021/02/16/%E5%AE%9E%E9%AA%8C4-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E4%B8%AD%E6%96%AD%E5%AE%9E%E9%AA%8C/6.png" alt="6"></p>
</li>
<li><p>最后，点击Generate Bitstream按键，生成bitstream文件。</p>
</li>
</ol>
<h2 id="三-应用程序编译、调试和执行"><a href="#三-应用程序编译、调试和执行" class="headerlink" title="三. 应用程序编译、调试和执行"></a>三. 应用程序编译、调试和执行</h2><ol>
<li><p>进入MIPSfpga_interrupt_C目录，在该目录下打开boot.S，init_cp0.S，mini_crt0.S，exception_entry.S和main.c等文件，仔细阅读这些文件，学习MIPSfpga处理器的中断服务是如何实现的。</p>
</li>
<li><p>用鼠标右键选择打开cmd命令窗口。在该命令窗口中输入make进行编译生成elf可执行文件。使用make clean命令可以将编译的结果清除。</p>
</li>
<li><p>连接Nexys4 DDR开发板bit文件下载线缆和MIPSfpga调试器。</p>
</li>
<li><p>打到Codescape_Scripts目录，在该目录下用鼠标右键选择打开cmd命令窗口。在命令窗口中输入如下命令运行loadMIPSfpga.bat批处理文件：</p>
<p> 格式： loadMIPSfpga.bat 空格 _C目录路径</p>
<p> 例：   loadMIPSfpga.bat ..\MIPSfpga_interrupt_C</p>
</li>
<li><p>同时打开一个串口终端，将波特率设置为115200，观察演示程序的运行情况。</p>
</li>
</ol>
<h2 id="四-动手实践"><a href="#四-动手实践" class="headerlink" title="四. 动手实践"></a>四. 动手实践</h2><ol>
<li><p>编写自定制外设模块PWM的中断服务程序，要求当PWM模块有中断请求时，将PWM的输入值设置为0。</p>
</li>
<li><p>尝试关闭MIPSfpga处理器系统的定时器中断，消除MIPSfpga处理器系统演示程序在运行一段时间后会不断进入定时中断的Bug。</p>
</li>
</ol>
<h2 id="五-小思考（自己思考就行，没有参考答案）"><a href="#五-小思考（自己思考就行，没有参考答案）" class="headerlink" title="五. 小思考（自己思考就行，没有参考答案）"></a>五. 小思考（自己思考就行，没有参考答案）</h2><p>1.为什么串口中断是1&lt;&lt;15？中断的原因存储在哪里？</p>
<p><strong>接口本质上</strong>是：</p>
<p><strong>硬件</strong>层面上：物理上CPU与设备的连接；</p>
<p><strong>软件</strong>层面上：实现设备对寄存器的操作</p>


      
        <div>
      
          <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
      
</div>
      

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/HUST_cs_jiekou/2021/02/15/%E5%AE%9E%E9%AA%8C5-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E6%A8%A1%E6%95%B0%E6%95%B0%E6%A8%A1%E8%BD%AC%E6%8D%A2/" rel="prev" title="实验5-MIPSfpag系统：模数数模转换">
      <i class="fa fa-chevron-left"></i> 实验5-MIPSfpag系统：模数数模转换
    </a></div>
      <div class="post-nav-item">
    <a href="/HUST_cs_jiekou/2021/02/17/%E5%AE%9E%E9%AA%8C3-MIPSfpag%E7%B3%BB%E7%BB%9F%EF%BC%9A%E8%87%AA%E5%AE%9A%E5%88%B6%E6%8E%A5%E5%8F%A3%E6%A8%A1%E5%9D%97/" rel="next" title="实验3-MIPSfpag系统：自定制接口模块">
      实验3-MIPSfpag系统：自定制接口模块 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%80-%E6%A6%82%E8%BF%B0"><span class="nav-text">一. 概述</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%8C-MIPSfpga%E5%A4%84%E7%90%86%E5%99%A8%E7%B3%BB%E7%BB%9F%E6%90%AD%E5%BB%BA"><span class="nav-text">二. MIPSfpga处理器系统搭建</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%89-%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%BC%96%E8%AF%91%E3%80%81%E8%B0%83%E8%AF%95%E5%92%8C%E6%89%A7%E8%A1%8C"><span class="nav-text">三. 应用程序编译、调试和执行</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%9B-%E5%8A%A8%E6%89%8B%E5%AE%9E%E8%B7%B5"><span class="nav-text">四. 动手实践</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%94-%E5%B0%8F%E6%80%9D%E8%80%83%EF%BC%88%E8%87%AA%E5%B7%B1%E6%80%9D%E8%80%83%E5%B0%B1%E8%A1%8C%EF%BC%8C%E6%B2%A1%E6%9C%89%E5%8F%82%E8%80%83%E7%AD%94%E6%A1%88%EF%BC%89"><span class="nav-text">五. 小思考（自己思考就行，没有参考答案）</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">华中科技大学计算机学院</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/HUST_cs_jiekou/archives/">
        
          <span class="site-state-item-count">9</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">华中科技大学计算机学院</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/HUST_cs_jiekou/lib/anime.min.js"></script>
  <script src="/HUST_cs_jiekou/lib/velocity/velocity.min.js"></script>
  <script src="/HUST_cs_jiekou/lib/velocity/velocity.ui.min.js"></script>

<script src="/HUST_cs_jiekou/js/utils.js"></script>

<script src="/HUST_cs_jiekou/js/motion.js"></script>


<script src="/HUST_cs_jiekou/js/schemes/muse.js"></script>


<script src="/HUST_cs_jiekou/js/next-boot.js"></script>




  















  

  

</body>
</html>
